## How do people evaluate foreign aid to “nasty” regimes?
## Tobias Heinrich & Yoshiharu Kobayashi
## British Journal of Political Science
#########################################################

## Check for dependences of the survey design

## Load inputs
##############
load("output/Modified MTurk Data.Rdata")
load("output/Weight vectors.Rdata")
data$w <- weight_vec[[1]][,1]

## Setup data
data <- subset(data, C == TC)
data2 <- ddply(.data=data, .variables=c("ID", "Round"), .fun=function(x) rearrange_data(x=x))
data2 <- subset(data2, C_R == TC_R & C_L == TC_L)

## Run models
m_L <- lm(formula=Rating_L ~ 1 + factor(C_R) + factor(B_R) + factor(PI_R), data=data2, weight=w)
m_R <- lm(formula=Rating_R ~ 1 + factor(C_L) + factor(B_L) + factor(PI_L), data=data2, weight=w)

m_LR <- lm(formula=Rating_R ~ 1 + I(PI_L == PI_R) + I(C_R == C_L) + I(B_R == B_L), data=data2, weight=w)
summary(m_LR)

b <- 0.5 * (mvrnorm(1000, coef(m_L), vcov(m_L)) + mvrnorm(1000, coef(m_R), vcov(m_R)))
colMeans(b > 0)



